package com.jewel.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import com.jewel.service.ProductService;


@Controller
public class ProductController {

    @Autowired
    private ProductService productService;


    @RequestMapping(value = "/product", method = RequestMethod.GET)
    public ModelAndView index(@RequestParam Integer productId){
        ModelAndView modelAndView = new ModelAndView();

        modelAndView.addObject("product", this.productService.getProductById(productId));

        modelAndView.setViewName("product");
        return  modelAndView;
    }
}
